package com.yyds.controller;

import com.yyds.common.R;
import com.yyds.pojo.VaccineVaccinator;
import com.yyds.service.PersonResidentVoService;
import com.yyds.service.VaccineVaccinatorService;
import com.yyds.service.VaccineVaccinatorVoService;
import com.yyds.service.VaccineVaccineService;
import com.yyds.vo.VaccineVaccinatorVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/admin/vaccine/vaccinator")
public class VaccineVaccinatorController {

    @Autowired
    @Qualifier("vaccineVaccineService")
    private VaccineVaccineService vaccineVaccineService;
    @Autowired
    @Qualifier("vaccineVaccinatorService")
    private VaccineVaccinatorService vaccineVaccinatorService;
    @Autowired
    @Qualifier("personResidentVoService")
    private PersonResidentVoService personResidentVoService;

    //添加人员接种信息
    @RequestMapping("/insertVaccinator")
    public R insertVaccineVaccinatorsVoController(VaccineVaccinatorVo vo) {
        System.out.println("insertVaccineVaccinatorsVoController vo = " + vo);
        //(vaccine_name=B型新冠疫苗, resident_name=打的)
        Integer i = vaccineVaccinatorService.insertVaccineVaccinatorService(vo);
        return i > 0 ? R.ok() : R.error();
    }

    //删除人员接种信息
    @RequestMapping("/deleteVaccinator")
    public R deleteVaccineVaccinatorsVoController(Integer vaccinator_id) {
        System.out.println("deleteVaccineVaccinatorsVoController vaccinator_id = " + vaccinator_id);
        Integer i = vaccineVaccinatorService.deleteVaccineVaccinatorService(vaccinator_id);
        return i > 0 ? R.ok() : R.error();
    }

    //删除部分人员接种信息
    @RequestMapping("/deleteAllVaccinator")
    public R deleteAllVaccineVaccinatorsVoController(String str) {
        Integer i = vaccineVaccinatorService.deleteAllVaccineVaccinatorService(str);
        return i > 0 ? R.ok() : R.error();
    }


    //修改人员接种信息
    @RequestMapping("/updateVaccinator")
    public R updateVaccineVaccinatorsVoController(VaccineVaccinatorVo vo) {
        System.out.println("updateVaccineVaccinatorsVoController vo =" + vo);
        Integer i = vaccineVaccinatorService.updateVaccineVaccinatorService(vo);
        return i > 0 ? R.ok() : R.error();
    }


    //查询全部疫苗名字
    @RequestMapping("/queryVaccineName")
    public R queryVaccineNameController() {
        List<String> list = vaccineVaccineService.queryVaccineNameService();
        return R.ok().data("vaccineName", list);
    }

    //查询全部人员姓名
    // queryResidentName
    @RequestMapping("/queryResidentName")
    public R queryResnidentNameController() {
        List<String> list = personResidentVoService.queryResidentNameService();
        return R.ok().data("residentName", list);
    }

}
